﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for DALStaff
/// </summary>
public class DALStaff :BaseDAL
{
    

	public DALStaff()
	{
	
	}

    public tblStaff login(string username, string password)
    {
        return db.tblStaffs.SingleOrDefault(c => c.Username == username && c.Password == password);
    }

    public void InsertStaff(tblStaff staff)
    {
        db.tblStaffs.InsertOnSubmit(staff);
        db.SubmitChanges();
    }

    public void updateStaff(tblStaff staff)
    {
        tblStaff s = db.tblStaffs.SingleOrDefault(c => c.ID == staff.ID);
        s.Password = staff.Password;
        s.BranchID = staff.BranchID;
        s.RoleID = staff.RoleID;
        db.SubmitChanges();
    }

    public List<tblStaff> ListStaff()
    {
        return db.tblStaffs.ToList();
    }

    internal tblStaff GetStaff(int staffid)
    {
        return db.tblStaffs.SingleOrDefault(c => c.ID == staffid);
    }
}